using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace TimeWar
{
    class WidescreenGraphicsDeviceManager : GraphicsDeviceManager
    {

        private bool isWideScreenOnly;
        static float WideScreenRatio = 1.6f; //1.77777779f;


        public WidescreenGraphicsDeviceManager(Game game)
            : base(game)
        {
        }


        public bool IsWideScreenOnly
        {
            get { return isWideScreenOnly; }
            set { isWideScreenOnly = value; }
        }


        protected override void RankDevices(List<GraphicsDeviceInformation> foundDevices)
        {
            base.RankDevices(foundDevices);


            if (IsWideScreenOnly)
            {
                for (int i = 0; i < foundDevices.Count; )
                {
                    PresentationParameters pp = foundDevices[i].PresentationParameters;
                    if (pp.IsFullScreen == true)
                    {
                        float aspectRatio = (float)(pp.BackBufferWidth) / (float)(pp.BackBufferHeight);

                        // If the device does not have a widescreen aspect ratio, remove it.
                        if (aspectRatio < WideScreenRatio)
                        {
                            foundDevices.RemoveAt(i);
                        }
                        else { i++; }
                    }
                    else i++;
                }

            }
        }






    }
}
